export namespace main {
	
	export class GlobalStats {
	    total: number;
	    active: number;
	    waiting: number;
	    completed: number;
	    failed: number;
	    speed: number;
	
	    static createFrom(source: any = {}) {
	        return new GlobalStats(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.total = source["total"];
	        this.active = source["active"];
	        this.waiting = source["waiting"];
	        this.completed = source["completed"];
	        this.failed = source["failed"];
	        this.speed = source["speed"];
	    }
	}
	export class LogEntry {
	    // Go type: time
	    time: any;
	    level: string;
	    message: string;
	
	    static createFrom(source: any = {}) {
	        return new LogEntry(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.time = this.convertValues(source["time"], null);
	        this.level = source["level"];
	        this.message = source["message"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Settings {
	    savePath: string;
	    maxConcurrent: number;
	    speedLimitKBs: number;
	    proxy: string;
	    lang: string;
	    maxActive: number;
	    retryMax: number;
	    btKeepSeeding: boolean;
	    btListenPort: number;
	    btTrackers: string;
	
	    static createFrom(source: any = {}) {
	        return new Settings(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.savePath = source["savePath"];
	        this.maxConcurrent = source["maxConcurrent"];
	        this.speedLimitKBs = source["speedLimitKBs"];
	        this.proxy = source["proxy"];
	        this.lang = source["lang"];
	        this.maxActive = source["maxActive"];
	        this.retryMax = source["retryMax"];
	        this.btKeepSeeding = source["btKeepSeeding"];
	        this.btListenPort = source["btListenPort"];
	        this.btTrackers = source["btTrackers"];
	    }
	}
	export class Task {
	    id: string;
	    name: string;
	    url: string;
	    type: string;
	    status: string;
	    size: number;
	    downloaded: number;
	    speed: number;
	    eta: number;
	    category: string;
	    savePath: string;
	    createdAt: number;
	    retryCount: number;
	
	    static createFrom(source: any = {}) {
	        return new Task(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.id = source["id"];
	        this.name = source["name"];
	        this.url = source["url"];
	        this.type = source["type"];
	        this.status = source["status"];
	        this.size = source["size"];
	        this.downloaded = source["downloaded"];
	        this.speed = source["speed"];
	        this.eta = source["eta"];
	        this.category = source["category"];
	        this.savePath = source["savePath"];
	        this.createdAt = source["createdAt"];
	        this.retryCount = source["retryCount"];
	    }
	}

}

